package com.bangyu.monitor.modular.system.model;

import cn.hutool.core.date.DateTime;
import com.bangyu.monitor.core.util.FormatUtil;
import com.bangyu.monitor.modular.system.entity.MaintainRecord;
import com.google.common.collect.Lists;
import lombok.Data;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang.StringUtils;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @Auther: zhangxue
 * @Date: 19/4/8 16:16
 * @Description:
 */
@Data
public class MaintainRecordDto {

    private Long id;
    //桥id
    private Long bridgeId;
    //梁编码
    private String beamNo;
    //维修日期
    private String maintainDate;
    //填表人
    private String person;
    private List<String> types;



    public static MaintainRecordDto moduleToDto(MaintainRecord record) {
        if (record == null) {
            return null;
        }
        MaintainRecordDto maintainRecordDto = new MaintainRecordDto();
        maintainRecordDto.setId(record.getId());
        maintainRecordDto.setBridgeId(record.getBridgeId());
        maintainRecordDto.setBeamNo(record.getBeamNo());
        maintainRecordDto.setMaintainDate(FormatUtil.parseInt2DateStr(record.getMaintainDate()));
        maintainRecordDto.setPerson(record.getPerson());
        String type = record.getType();

        if(StringUtils.isNotEmpty(type)){
         String[] var1 = type.split(",");
            maintainRecordDto.setTypes(Lists.newArrayList(var1));
        }
        return maintainRecordDto;
    }


}
